//
//  DBYRoadTableViewCell.m
//  MemoryTravel
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "DBYRoadTableViewCell.h"

@implementation DBYRoadTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

    [self creatSubViews];
        
    }
    return self;
}


-(void)creatSubViews
{
    
    self.image_urlImageView = [[UIImageView alloc]init];
    self.image_urlImageView.userInteractionEnabled = YES;
    [self.contentView addSubview:self.image_urlImageView];
    [self.image_urlImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(5);
        make.size.mas_equalTo(CGSizeMake(Width - 10, 160));
        
    }];
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.text = @"日本全景7日游";
    self.nameLabel.textColor = [UIColor whiteColor];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:18];
    self.nameLabel.numberOfLines = 0;

    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.image_urlImageView.mas_bottom).offset(-50);
        make.left.equalTo(self.image_urlImageView.mas_left).offset(5);
        make.size.mas_equalTo(CGSizeMake(Width - 20, 30));
    }];
    
    
    self.dayLabel = [[UILabel alloc]init];
    self.dayLabel.textColor = [UIColor whiteColor];
    self.dayLabel.text = @"7天 / 38个旅行地";
    self.dayLabel.font = [UIFont systemFontOfSize:15];

    [self.contentView addSubview:self.dayLabel];
    [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.image_urlImageView.mas_bottom).offset(-20);
        make.left.equalTo(self.image_urlImageView.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(Width - 20, 20));
        
        
    }];
    
    self.descriptionLabel = [[UILabel alloc]init];
    self.descriptionLabel.textColor = [UIColor blackColor];
    self.descriptionLabel.text = @"京都的优雅,东京大阪的时尚,富士山的秀美,北海道的浪漫一次体验,7天最全面的日本游线路";
    self.descriptionLabel.numberOfLines = 0;
    self.descriptionLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.descriptionLabel];
    [self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.image_urlImageView.mas_bottom).offset(5);
        make.left.equalTo(self.image_urlImageView);
        make.size.mas_equalTo(CGSizeMake(Width - 20, 50));
        
    }];
    
}

-(void)setRoadModel:(DBYRoadModel *)roadModel
{
    
    if (_roadModel != roadModel) {
        
        _roadModel = roadModel;
    }
    
    self.nameLabel.text = self.roadModel.name;
    self.descriptionLabel.text = self.roadModel.myDescription;
    [self.descriptionLabel sizeToFit];
    
    
    NSString *count = [NSString stringWithFormat:@"%@天 / %@个旅行地", self.roadModel.plan_days_count, self.roadModel.plan_nodes_count];
    self.dayLabel.text = count;
    
    
    [self.image_urlImageView sd_setImageWithURL:[NSURL URLWithString:self.roadModel.image_url] placeholderImage:[UIImage imageNamed:@"loading.jpg"]];

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
